package com.zr.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zr.service.UserService;

/**
 * 查询用户信息的servlet
 * @author Administrator
 *
 */
public class SelectUserController extends HttpServlet {
	//实例化对应的服务层
	UserService userservice = new UserService();
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	// TODO Auto-generated method stub
	doPost(req, resp);
}
@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
	//拿到页面传过来的page，rows值
	 String page = req.getParameter("page");
	 String rows = req.getParameter("rows");
	 //初始的记录数
	 int start = (Integer.parseInt(page)-1)*Integer.parseInt(rows);
	 resp.setCharacterEncoding("utf8");
	 //获取回复的那只笔
	 PrintWriter  pw = resp.getWriter();
	 //调取对应的服务
	 pw.write(userservice.findAllUser(start, Integer.parseInt(rows)).toString());
	}
}
